package h0807;

import java.util.*;

/**
  * @description 打印任务排序
  * @author 不知名帅哥
  * @date 2024/8/7 9:19
  * @version 1.0
*/
public class PrintTaskSort {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int[] priorities = Arrays.stream(sc.nextLine().split(",")).mapToInt(Integer::parseInt).toArray();
        List<List<Integer>> res = getList(priorities);
        StringJoiner ans=new StringJoiner(" ");
        for (int priority : priorities) {
            for (List<Integer> re : res) {
                if (re.get(1)==priority){
                    ans.add(re.get(0)+"");
                    res.remove(re);
                    break;
                }
            }
        }
        System.out.println(ans);
    }

    private static List<List<Integer>> getList(int[] priorities) {
        //如何判断后续含有比当前元素优先级更高的
        //初始化
        LinkedList<Integer> origin=new LinkedList<>();
        for (int priority : priorities) {
            origin.add(priority);
        }
        List<Integer> temp=new ArrayList<>(origin);
        Collections.sort(temp);

       List<List<Integer>> res=new ArrayList<>();
        int index=0;
        while (!origin.isEmpty()){
            //如果origin第一个元素不是最高优先级，证明还有更高的。需要放到队尾
            if (!origin.peekFirst().equals(temp.get(temp.size()-1))){
                Integer first = origin.removeFirst();
                origin.addLast(first); //放到队尾
            }else {
                ArrayList<Integer> list = new ArrayList<>();
                list.add(index);
                list.add(origin.removeFirst());
                res.add(list); //第一个
                temp.remove(temp.size()-1);
                //移除队头
                index++;
            }
        }
        return res;
    }
}
